#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <string.h>
#include <signal.h>
#include <dlfcn.h>
#include <sys/types.h>          /* See NOTES */
#include <sys/socket.h>
#include "workerpub.h"

typedef int (*SoMain)();
int LoadLibrary(char *filename, void** ppHandle)
{
	void *handle;
	char *error = NULL;

	handle = dlopen(filename, RTLD_LAZY);
	if (!handle) {
		fprintf(stderr, "%s\n", dlerror());
		return -1;
	}
	*ppHandle = handle;
	return 0;
}
int GetStartfunc(void *pHandle, char* funcname, int (**func)())
{
	char *error = NULL;
	*func = dlsym(pHandle,funcname); 
	if ((error = dlerror()) != NULL)  {
		fprintf(stderr, "%s\n", error);
		return -1;
	}
	return 0;
}

int main()
{
	void *pHandle = NULL;
	LoadLibrary("./librenrendai.so", &pHandle);

	int (*func)();
printf("ii\n");
	GetStartfunc(pHandle, "SoMain", &func);

printf("jj\n");
	func();
printf("hh\n");
	return 0;
}
